package com.xiqin.security.bean;

import com.xiqin.microservicebean.system.SystemUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @Author TaoQiansheng
 * @Date 2020-05-07 13:53
 * @Version 1.0
 */
@Data
public class CustomerUserDetail extends SystemUser implements UserDetails {

    private List<CustomerAuthority> authorities;

    public CustomerUserDetail() {
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return super.getPassword();
    }

    @Override
    public String getUsername() {
        return super.getUserName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return this.getDeleteFlag()==0;
    }

    @Override
    public boolean isAccountNonLocked() {
        return this.getIsLock()==0;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.getStatus()==1;
    }
}
